<?php
include "../tambah/date.php";
include "../txt/url.php";
$per_page=5;
include_once('../Connections/sepolwan_connect.php');
if(isset($_POST['pageLimit']) && !empty($_POST['pageLimit'])){
    $pageLimit=$_POST['pageLimit'];
}else{
    $pageLimit='0';
}
$pageLimit=$pageLimit;

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}
mysql_select_db($database_sepolwan_connect, $sepolwan_connect);
$query_ambil_berita = "SELECT * FROM artikel WHERE jenis = '".$_GET['jenis']."' ORDER BY id DESC Limit ".$pageLimit.",".$per_page;
$ambil_berita = mysql_query($query_ambil_berita, $sepolwan_connect) or die(mysql_error());
$row_ambil_berita = mysql_fetch_assoc($ambil_berita);
$totalRows_ambil_berita = mysql_num_rows($ambil_berita);
?>
<?php if ($totalRows_ambil_berita > 0) { // Show if recordset not empty ?>
  <?php do { ?>
    <strong style="font-size:14px"><a href="<?php echo $base ?>detail-<?php echo $row_ambil_berita['id']; ?>/<?php echo str_replace(array(' ', '`', '~', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', '=', '{', '}', '|', ',', ':', ';', '"', '<', '>', ',', '.', '?', '/'), '-', $row_ambil_berita['judul']); ?>.html"><?php echo $row_ambil_berita['judul']; ?></a></strong><br />
    <?php echo tgl_indo($row_ambil_berita['waktu']); ?> | dilihat: <?php echo $row_ambil_berita['view']; ?> orang | komentar: <?php echo $row_ambil_berita['comment']; ?>
    <div style="width:100%; height:118px; margin-top:10px; text-align:justify">
      <div style="width:150px; height:90px; background:#000; overflow:hidden; float:left; border:1px solid #CCC; margin-right:10px; margin-bottom:10px"><img src="<?php echo $base ?>images/artikel/small/<?php echo $row_ambil_berita['image']; ?>" /></div>
      <div style="text-align:justify; margin-bottom:10px"><?php echo substr($row_ambil_berita['desk'],0,150); ?> <a href="<?php echo $base ?>detail-<?php echo $row_ambil_berita['id']; ?>/<?php echo str_replace(array(' ', '`', '~', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', '=', '{', '}', '|', ',', ':', ';', '"', '<', '>', ',', '.', '?', '/'), '-', $row_ambil_berita['judul']); ?>.html"><br />
        [selengkapnya]</a></div>
    </div>
    <div style="width:100%; height:1px; background:#CCC; margin-bottom:20px"></div>
    <?php } while ($row_ambil_berita = mysql_fetch_assoc($ambil_berita)); ?>
  <?php
$loadCount=$pageLimit+$per_page;
 if($totalRows_ambil_berita >= $per_page){ ?>
       <div class="load_more_link">
       <input type="button" class="button" value="Load More" 
       onclick=loadData(<?php echo $loadCount ?>)>
       <span class="flash"></span></div> <?php
 }
}else{
       echo 'No Data Found';
}
  
mysql_free_result($ambil_berita);
?>